#!/bin/bash


echo ""
echo -n "Removing old test file..."
if [ -f test.exe ]
	then
		rm test.exe
		rm parrotlog*
		rm parrotcommand*
		rm intrajointratetest*
fi
echo "done"

TESTFILE=test.cpp
if [ $# -ge 1 ]; then
	TESTFILE=$1
fi

echo -n "Building static library if needed..."

if [ ! -f libBrownie.a ]
	then
		./build_static.win >/dev/null 2>static_build_output.txt
fi

if [ ! -f libBrownie.a ]; then
	echo "error building the static library"
	exit
else
	echo "done"	
fi


echo ""
echo ""
echo ""
echo -n "Compiling test file ... "
echo ""
echo ""

rm *.o
rm *.exe
g++ -g ${TESTFILE} -I"." -L/usr/lib -L"." -I"./ncl-2.0/src" -I"./TreeLib" -I"./TreeLib/gport" -I/usr/includes -lBrownie -lgsl -lgslcblas -lm  -o test.exe

echo "done"
echo ""
echo ""
ls -alt | head -10


./test.exe
